

import pygame

from settings import *



class Generic(pygame.sprite.Sprite):
    def __init__(self,pos,surf,groups,z=LAYERS['main']):
        super().__init__(groups)
        self.image =surf
        self.rect = self.image.get_rect(topleft=pos)
        self.z = z
        #物体碰撞体积
        self.hitbox=self.rect.copy().inflate(-self.rect.width*0.2,-self.rect.height*0.6)




class Water(Generic):
    def __init__(self,pos,frames,groups):
         #动画
        self.frames = frames
        self.frames_index = 0

        super().__init__(pos=pos,surf=self.frames[self.frames_index],groups=groups,z=LAYERS['water']
                         )

    def animation(self,dt):
        self.frames_index += 5*dt
        if self.frames_index >= len(self.frames):
            self.frames_index = 0

        self.image = self.frames[int(self.frames_index)]

    def update(self,dt):
        self.animation(dt)



